load("//bzl:cpp_library.bzl", "cpp_library")
load("//bzl:cpp_unittest.bzl", "cpp_unittest")

package(default_visibility = ["//visibility:public"])

cpp_unittest(
    name = "AsyncTest",
    srcs = ["AsyncTest.cpp"],
    deps = [
        "//folly/executors:async",
        "//folly/executors:manual_executor",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "CodelTest",
    srcs = ["CodelTest.cpp"],
    deps = [
        "//folly/executors:codel",
        "//folly/portability:gflags",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "FiberIOExecutorTest",
    srcs = ["FiberIOExecutorTest.cpp"],
    deps = [
        "//folly/executors:fiber_io_executor",
        "//folly/executors:io_thread_pool_executor",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "executor_test",
    srcs = ["ExecutorTest.cpp"],
    deps = [
        "//folly/executors:inline_executor",
        "//folly/executors:manual_executor",
        "//folly/executors:queued_immediate_executor",
        "//folly/futures:core",
        "//folly/io/async:request_context",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
    ],
)

cpp_unittest(
    name = "GlobalExecutorTest",
    srcs = ["GlobalExecutorTest.cpp"],
    deps = [
        "//folly/executors:cpu_thread_pool_executor",
        "//folly/executors:global_executor",
        "//folly/executors:io_executor",
        "//folly/executors:io_thread_pool_executor",
        "//folly/executors:virtual_executor",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
        "//folly/synchronization:saturating_semaphore",
        "//folly/system:hardware_concurrency",
    ],
)

cpp_unittest(
    name = "GlobalCPUExecutorTest",
    srcs = ["GlobalCPUExecutorTest.cpp"],
    deps = [
        "//folly/executors:cpu_thread_pool_executor",
        "//folly/executors:global_executor",
        "//folly/executors:io_executor",
        "//folly/executors:io_thread_pool_executor",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
    ],
)

cpp_unittest(
    name = "GlobalIOExecutorTest",
    srcs = ["GlobalCPUExecutorTest.cpp"],
    deps = [
        "//folly/executors:cpu_thread_pool_executor",
        "//folly/executors:global_executor",
        "//folly/executors:io_executor",
        "//folly/executors:io_thread_pool_executor",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
    ],
)

cpp_unittest(
    name = "GlobalExecutorAssignmentTest",
    srcs = ["GlobalExecutorAssignmentTest.cpp"],
    deps = [
        "//folly:singleton",
        "//folly/executors:cpu_thread_pool_executor",
        "//folly/executors:global_executor",
        "//folly/executors:inline_executor",
        "//folly/executors:io_executor",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
    ],
)

cpp_unittest(
    name = "SerialExecutorTest",
    srcs = ["SerialExecutorTest.cpp"],
    deps = [
        "//folly:random",
        "//folly:scope_guard",
        "//folly/executors:cpu_thread_pool_executor",
        "//folly/executors:inline_executor",
        "//folly/executors:serial_executor",
        "//folly/io/async:request_context",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
    ],
)

cpp_unittest(
    name = "SequencedExecutorTest",
    srcs = ["SequencedExecutorTest.cpp"],
    deps = [
        "//folly/executors:cpu_thread_pool_executor",
        "//folly/executors:serial_executor",
        "//folly/io/async:scoped_event_base_thread",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "StrandExecutorTest",
    srcs = ["StrandExecutorTest.cpp"],
    deps = [
        "//folly:cancellation_token",
        "//folly/executors:global_executor",
        "//folly/executors:manual_executor",
        "//folly/executors:strand_executor",
        "//folly/io/async:request_context",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
    ],
)

cpp_unittest(
    name = "ThreadedExecutorTest",
    srcs = ["ThreadedExecutorTest.cpp"],
    deps = [
        "//folly:conv",
        "//folly/executors:threaded_executor",
        "//folly/futures:core",
        "//folly/gen:base",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "ThreadPoolExecutorTest",
    size = "medium",
    srcs = ["ThreadPoolExecutorTest.cpp"],
    deps = [
        "//folly:c_portability",
        "//folly:default_keep_alive_executor",
        "//folly:exception",
        "//folly/container:f14_hash",
        "//folly/executors:cpu_thread_pool_executor",
        "//folly/executors:edf_thread_pool_executor",
        "//folly/executors:future_executor",
        "//folly/executors:io_thread_pool_executor",
        "//folly/executors:thread_pool_executor",
        "//folly/executors:virtual_executor",
        "//folly/executors/task_queue:lifo_sem_mpmc_queue",
        "//folly/executors/task_queue:unbounded_blocking_queue",
        "//folly/executors/thread_factory:init_thread_factory",
        "//folly/executors/thread_factory:priority_thread_factory",
        "//folly/lang:keep",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
        "//folly/portability:pthread",
        "//folly/portability:sys_resource",
        "//folly/synchronization:latch",
        "//folly/synchronization/detail:spin",
        "//folly/system:thread_id",
        "@boost.thread",
    ],
)

cpp_unittest(
    name = "TimedDrivableExecutorTest",
    srcs = ["TimedDrivableExecutorTest.cpp"],
    deps = [
        "//folly/executors:timed_drivable_executor",
        "//folly/futures:core",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
    ],
)

cpp_unittest(
    name = "TimekeeperScheduledExecutorTest",
    srcs = ["TimekeeperScheduledExecutorTest.cpp"],
    deps = [
        "//folly/executors:inline_executor",
        "//folly/executors:serial_executor",
        "//folly/executors:threaded_executor",
        "//folly/executors:timekeeper_scheduled_executor",
        "//folly/futures:manual_timekeeper",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
    ],
)

cpp_unittest(
    name = "ExecutorWithPriorityTest",
    srcs = ["ExecutorWithPriorityTest.cpp"],
    deps = [
        "//folly/executors:cpu_thread_pool_executor",
        "//folly/executors:executor_with_priority",
        "//folly/futures:core",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "MeteredExecutorTest",
    srcs = ["MeteredExecutorTest.cpp"],
    deps = [
        "//folly:benchmark",
        "//folly:synchronized",
        "//folly/coro:blocking_wait",
        "//folly/coro:task",
        "//folly/executors:cpu_thread_pool_executor",
        "//folly/executors:metered_executor",
        "//folly/init",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
        "//folly/synchronization:latch",
        "//folly/synchronization:lifo_sem",
        "//folly/test:deterministic_schedule",
    ],
)

cpp_library(
    name = "IOThreadPoolExecutorBaseTestLib",
    hdrs = [
        "IOThreadPoolExecutorBaseTestLib.h",
    ],
    deps = [
        "//folly:random",
        "//folly/container:f14_hash",
        "//folly/executors:io_thread_pool_executor",
        "//folly/io/async:async_base",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
        "@fmt",
        "@glog",
    ],
)

cpp_unittest(
    name = "function_scheduler_test",
    size = "medium",
    srcs = ["FunctionSchedulerTest.cpp"],
    deps = [
        "//folly:random",
        "//folly/executors:function_scheduler",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
        "@boost.thread",
        "@glog",
    ],
)

cpp_unittest(
    name = "threaded_repeating_function_runner_test",
    srcs = ["ThreadedRepeatingFunctionRunnerTest.cpp"],
    deps = [
        "//folly/executors:threaded_repeating_function_runner",
        "//folly/portability:gtest",
    ],
)
